//二次封装axios   针对mock
import axios from 'axios'
//引入请求进度条
import nProgress from 'nprogress'
//引入请求进度条的样式
import 'nprogress/nprogress.css'

const mockAjax = axios.create({
  baseURL: '/mock',
  timeout: 10000
})

//请求拦截器
mockAjax.interceptors.request.use((config) => {
    return config
    nProgress.start()
  })
  //响应拦截器
mockAjax.interceptors.response.use((res) => {
  return res.data
  nProgress.done()
}, (err) => {
  alert('请求数据失败')
})


//暴露mockAjax
export default mockAjax